import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../bottom_navigation_bar.dart';

class MessagePage extends StatefulWidget {

  final String title;

  const MessagePage( {super.key,this.title='新闻页面'});

  @override
  State<MessagePage> createState() => _HomePageState();
}

class _HomePageState extends State<MessagePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title), // 标题
      ),
      body: Column(
        children: <Widget>[
          Text('这是消息页面'),
          SizedBox(height: 20),
          ElevatedButton(
            child: Text('命名路由传值'),
            onPressed: () {
              Navigator.pushNamed(context, "/form", arguments: {"id": 1, "name": "张三"});
            },
          ),
          ElevatedButton(
            child: Text('轮播图pageViewSwiper'),
            onPressed: () {
              Navigator.pushNamed(context, "/pageViewSwiper");
            },
          ),
          ElevatedButton(
            child: Text('轮播图pageViewKeepAlive'),
            onPressed: () {
              Navigator.pushNamed(context, "/pageViewKeepAlive");
            },
          ),
          ElevatedButton(
            child: Text('返回根目录'),
            onPressed: () {
              //Get.offAllNamed('/');
              Get.offAll(BottomNavigationBarPage(arguments: 4));
              //通过Getx获取本地存储

            },
          ),
        ]
      ),
      //
      //返回到上一页，如果本身就子当前页就不显示返回上一页按钮
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.arrow_back),
        onPressed: () {
          Navigator.of(context).pop();
        },
        tooltip: '返回上一页',
        backgroundColor: Colors.blue,
        foregroundColor: Colors.white,
        elevation: 10,
      )

    );
  }
}
